home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of MacTutor - S…e Code for Volumes 1 to 5
/
The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin
/
Source Code
/
#05 (Dec85-Jan86)
/
modula2
/
serial ports 2-1
/
SCCHack.MOD
< prev
Wrap
Text File
|
1985-11-23
|
2KB
|
80 lines
MODULE SCCHack;
(* Written by Jeff Mitchell
Digital Solutions, 1985
This program allows interactive manipulation
of the internal SCC registers. It uses only
channel A but I've included the offsets for
channel B for reference. *)
FROM Terminal IMPORT Read,Write,WriteLn,
WriteString,ClearScreen;
FROM InOut IMPORT ReadInt,WriteHex;
CONST
(* Offsets into SCC registers *)
aData = 6; (* A channel data *)
aCtl = 2; (* A channel control *)
bData = 4; (* B channel data *)
bCtl = 0; (* B channel control *)
cntl_B = 2; (* ASCII value *)
cntl_C = 3; (* ASCII value *)
NULL = 0; (* ASCII value *)
TYPE
SerPtr = POINTER TO ARRAY [0..6] OF CHAR;
(* Needed for byte access *)
VAR
SCCRd [1D8H]: SerPtr; (* Read pointer *)
SCCWr [1DCH]: SerPtr; (* Write pointer *)
ch: CHAR;
reg: INTEGER;
BEGIN (* SCCHack *)
ClearScreen;
ch:= SCCRd^[aCtl]; (* Ensure ptr reg = 0 *)
REPEAT
WriteString('Which register ? ');
ReadInt(reg);
WriteLn;
SCCWr^[aCtl]:= CHR(reg); (* Set pointer *)
REPEAT
WriteString('Read or Write? ');
Read(ch);
Write(ch);
WriteLn
UNTIL (CAP(ch) = 'R') OR (CAP(ch) = 'W');
IF (CAP(ch) = 'R') THEN
ch:= SCCRd^[aCtl]; (* Read register *)
WriteHex(CARDINAL(ch),4); (* Display in hex *)
WriteLn
ELSE
WriteString('Register Value? ');
ReadInt(reg); (* Integer value, not hex *)
WriteLn;
WriteString('Hex equivalent = ');
WriteHex(CARDINAL(reg),4);
WriteLn;
SCCWr^[aCtl]:= CHR(reg) (* Write to register *)
END;
REPEAT
WriteString('Try another? '); (* Fun, huh? *)
Read(ch);
Write(ch);
WriteLn
UNTIL (CAP(ch) = 'Y') OR (CAP(ch) = 'N');
WriteLn
UNTIL (CAP(ch) <> 'Y')
END SCCHack.